/*
 * This file is part of ksPlatform
 * 
 * Copyright (c) 2014-2015
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at 97041437@qq.com.
 */
package cn.com.ksplatform.modules.system.auth.sessionmanager.util;

import javax.servlet.http.HttpSession;

import cn.com.ksplatform.modules.system.auth.loginmanager.controller.LoginCons;
import cn.com.ksplatform.modules.system.auth.sessionmanager.model.OnlineModel;
import cn.com.ksplatform.modules.system.auth.usermanager.model.PlatUser;

/**
 * ClassName:SessionOnlineUtil.java <br/>
 * Date: 2015年12月4日 <br/>
 * 
 * @author Mr.Xiao
 * @version 1.0
 */
public class SessionOnlineUtil {
	public static OnlineModel getOnlineModel(HttpSession session){
		PlatUser user = (PlatUser) session.getAttribute(LoginCons.LOGIN_USER);
		String ip = session.getAttribute(LoginCons.LOGIN_IP).toString();
		String user_name = user.getUserName();
		OnlineModel o = new OnlineModel(session.getId(), user_name, ip, session.getCreationTime());
		return o;
	}
}
